<? if ($user->pAdmin && ($user->id != $this->user->id)): ?>
	<b><?=$user->pEmail?></b><br/>
	<b><?=$user->pName?></b>
	<h2>АДМИН</h2>
<? else:?>

<form method="post" action="/admin/users/save">
	<? if ($user->pEmail): ?>
		<b><a href="mailto:<?=$user->pEmail?>"><?=$user->pEmail?></a></b>
		<br/>
	<? endif; ?>
	<input type="hidden" name="id" value="<?=$user->id?>" />
	Имя:<br/>
	<input type="text" name="pName" value="<?=$user->pName?>" /> <br/>

	<div class="userDates">
		Зарегистрирован: <?=printDate($user->dReg, true)?>
	</div>

	<? if ($socs): ?>
	<div>
	<? foreach ($socs as $soc): ?>
		<?
			$link = false;
			$imgLink = false;
			switch ($soc->pMethod) {
				case 'ok':
					$link = 'http://www.odnoklassniki.ru/profile/'.$soc->tUid;
					$imgLink = 'ok';
					break;
				case 'mailru':
					$link = $soc->pLink;
					$imgLink = 'mailru';
					break;
				case 'vk':
					$link = 'http://vk.com/id'.$soc->tUid;
					$imgLink = 'vk';
					break;
				case 'fb':
					$link = 'http://www.facebook.com/'.$soc->tUid;
					$imgLink = 'fb';
					break;
				case 'twitter':
					$link = 'https://twitter.com/account/redirect_by_id?id='.$soc->tUid;
					$imgLink = 'twitter';
					break;
			}
		?>
		<? if ($imgLink & $link): ?>
			<a href="<?=$link?>" target="_blank"> <img src="<?=base_url()?>img/sicon_<?=$imgLink?>.png" > </a>
		<? endif; ?>
	<? endforeach; ?>
	</div>
	<? endif; ?>
	
	<? if ($user->pAdmin): ?>
		<h2>АДМИН</h2>
	<? elseif ($this->user->data->pAdmin || $this->user->checkRight(3)):?>
		<input type="checkbox" id="pAdminInput" name="pModer[0]" value="1" <?=$user->pModer?'checked="true"':''?> />
			<label for="pAdminInput">Модератор</label><br/>
			<table id="rightsTable" <?=$user->pModer?'':'style="display:none"'?>>
				<tr>
					<td>Добавление статей</td>
					<td><input type="checkbox" id="right_1" name="pModer[1]" <?=(strpos($user->pModer, '1') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Редактирование/утверждение чужих статей</td>
					<td><input type="checkbox" id="right_2" name="pModer[2]" <?=(strpos($user->pModer, '2') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Редактирование пользователей</td>
					<td><input type="checkbox" name="pModer[3]" <?=(strpos($user->pModer, '3') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Добавление/редактирование страниц</td>
					<td><input type="checkbox" name="pModer[4]" <?=(strpos($user->pModer, '4') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Редактирование блоков</td>
					<td><input type="checkbox" name="pModer[5]" <?=(strpos($user->pModer, '5') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Шаблоны писем/рассылки</td>
					<td><input type="checkbox" name="pModer[6]" <?=(strpos($user->pModer, '6') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Редактирование комментариев</td>
					<td><input type="checkbox" name="pModer[7]" <?=(strpos($user->pModer, '7') !== false)?'checked="true"':''?>/></td>
				</tr>
				<tr>
					<td>Просмотр статей</td>
					<td><input type="checkbox" name="pModer[8]" <?=(strpos($user->pModer, '8') !== false)?'checked="true"':''?>/></td>
				</tr>
			</table>
	<? endif;?>
	
<?
	/* Смена пароля
	**********************/
	if ($user->id == $this->user->id):?>
	<div style="border:1px solid #ddd; padding: 10px; display: table;">
		Введите новый пароль:<br/>
		<input type="password" name="pwd_1"/><br/>
		Повторите пароль:<br/>
		<input type="password" name="pwd_2"/><br/>
	</div>
<? endif;?>
	<input type="submit" value="Сохранить" /> <br/>
</form>

<script>
	$("#pAdminInput").change(function(){
		if ($(this).is(':checked'))
			$("#rightsTable").show();
			else
			$("#rightsTable").hide();
	})
	
	$("#right_2").change(function(){
		if ($(this).is(':checked'))
			$("#right_1").attr('checked', true);
	})
</script>
<? endif;?>